<!-- 侧边栏 -->
<template>
    <div class="asdise_content">
        <div class="asdise_content_main" v-if="nav_value == 0">
            <div class="asdise_content_main_header">
                <img  class="touxiang" v-if="basic.imageUrl" :src="basic.imageUrl" mode="" />
                <img  v-else class="touxiang" src="/img/testimage.png" alt="" />
                <div :class="basic.sex == '0' ? 'nan sex' :basic.sex == '1'? 'nv sex':''">
                    <img v-if="basic.sex == '0'" src="/img/nan.png" alt="" />
                    <img v-else-if="basic.sex == '1'" src="/img/nv.png" alt="" />
                </div>
            </div>
            <div class="asdise_content_main_name flex jcc aic">
                <span class="fontz fonts24 fontw700" v-if="edit">{{ basic.name }}</span>
                <div class="asdise_content_main_name_input" v-else>
                    <el-input v-model="input" placeholder="请输入姓名"></el-input>
                </div>
                <!-- <div class="asdise_content_main_name_edit">
                    <img src="/img/edit-3.png" alt="" @click="editClick()" />
                </div> -->

            </div>
            <div class="flex jcc aic">
                <p class="fontz fonts18 gary">{{ basic.age }} | {{ basic.educationLevel }} | {{ basic.startWorkTime }}</p>
            </div>
            <!-- <div class="" style="padding: 32px 21px;">
                <el-select v-model="value" placeholder="请选择" style="width: 100%;">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </div> -->
            <div class="td_grid cursor_pointer" >
                <div :class="indexTd==3?'asdise_content_main_name_divs':'asdise_content_main_name_div'"  @click="countClick(3)">
                    <p class="fontz fonts14 garys">已投递</p>
                    <p class="fontz fonts18 garys_">{{ basic.deliveredCount }}</p>
                </div>
                <div :class="indexTd==4?'asdise_content_main_name_divs':'asdise_content_main_name_div'" @click="countClick(4)">
                    <p class="fontz fonts14 garys" >邀请投递</p>
                    <p class="fontz fonts18 garys_">{{ basic.invitedCount }}</p>
                </div>
                <div :class="indexTd==5?'asdise_content_main_name_divs':'asdise_content_main_name_div'" @click="countClick(5)">
                    <p class="fontz fonts14 garys">收藏</p>
                    <p class="fontz fonts18 garys_" >{{ basic.collectedCount }}</p>
                </div>
            </div>
        </div>
        <div class="asdise_content_title fonts24 fontz fontw700 flex aic" v-if="nav_value == 1 || nav_value == 2">
            {{ nav_value == 1 ? "简历信息" : "账号管理" }}
        </div>
        <ul class="asdise_content_ul" v-if="nav_value != 3">
            <li class="cursor_pointer" :class="indexValue == item.id ? 'blue' : ''" v-for="(item, index) in nowData" :key="index"
                @click="classClick(item)">
                <span class="fontz fonts18">{{ item.label }}</span>
                <img v-if="indexValue == item.id" class="" src="/img/r1.png" alt="" srcset="" />
                <img v-else class="" src="/img/rw1.png" alt="" srcset="" />
            </li>
        </ul>
        <!-- 职位详情页 -->
        <div class="zhiweidetail_content" v-if="nav_value == 3 ">
            <div class="flex zhiweidetail_content_header flex jcsb aic" @click="go()">
                <img src="/img/c1.png" alt="" v-if="!companyData.tenantVo.companyLogoUrl" />
                <img :src="companyData.tenantVo.companyLogoUrl" alt="" v-if="companyData.tenantVo.companyLogoUrl" />
                <div class="zhiweidetail_content_header_main">
                    <p class="fontz fonts18 fontw700" style="padding: 0;margin: 0;">{{ companyData.tenantVo.companyName }}
                    </p>
                    <div style="margin-top: 6px;">
                        <img src="/img/c1.png" alt="" srcset="" />
                        <span v-if="loadings" class="fontz fonts14 gary">{{ dict(companyData.tenantVo.companyType, "company_type") }}</span>
                    </div>
                    <div style="margin-top: 6px;">
                        <img src="/img/c2.png" alt="" srcset="" />
                        <span class="fontz fonts14 gary" v-if="loadings">{{ dict(companyData.tenantVo.companyIndustry, "company_industry")
                        }}</span>
                    </div>
                    <div style="margin-top: 6px;">
                        <img src="/img/c3.png" alt="" srcset="" />
                        <span class="fontz fonts14 gary" v-if="loadings">{{ dict(companyData.tenantVo.companySize, "company_size") }}</span>
                    </div>
                </div>
                <div class="zhiweidetail_content_header_r">
                    <img src="/img/rw1.png" alt="" />
                </div>

            </div>
            <p class="fontz fonts18 ">公司其他职位</p>
            <ul class="zhiweidetail_content_ul">
                <li :class="indexVli == index ? 'zhiweidetail_content_li' : ''" v-for="(personData, index) in posData"
                    :key="index" @click="indexClick(personData, index)">
                    <div class="flex jcsb">
                        <span class="fontz fonts18 fontw700">{{ personData.positionName }}</span>
                        <span class="fontz fonts20 red">{{ personData.salaryStart }}-{{ personData.salaryEnd }}{{
                            personData.salaryUnit }}
                            {{ personData.salaryRange }}薪</span>
                    </div>
                    <p class=" fonts18 fontz gary" style="margin-top: 16px;">{{ dict(personData.requirementsYears,
                        "requirements_years") }}
                        | {{ dict(personData.educationRequirements, "education") }} | {{ personData.applicationAddress }}
                    </p>
                </li>
            </ul>

        </div>
    </div>
</template>
  
<script>
import { positionList, getDetailTenant } from "@/api/my.js"
import { dictSect, dictFuns, dictFun } from "@/utils/dictUnit"
export default {
    props: {
        nav_value: {
            type: Number,
            default: 0
        },
        companyData: {
            type: Object,
            default: {}
        },
        refush:{}
    },
    name: 'Asdise',
    data() {
        return {
            loadings: false,
            basic: {},
            options: [],
            value: "",
            edit: true,
            input: '',
            sex: 0,
            indexValue: -1,
            nowData: [],
            nowDatas: [{
                id: 0,
                label: "首页"
            }, {
                id: 1,
                label: "投递进度"
            }, {
                id: 2,
                label: "我的简历"
            }],
            navData: [
                {
                    id: 0,
                    label: "个人信息"
                },
                {
                    id: 1,
                    label: "求职意向"
                },
                {
                    id: 2,
                    label: "工作经历"
                },
                {
                    id: 3,
                    label: "教育经历"
                },
                {
                    id: 4,
                    label: "项目经历"
                },
                {
                    id: 5,
                    label: "培训经历"
                },
                {
                    id: 6,
                    label: "专业技能"
                },
                {
                    id: 7,
                    label: "资格证书"
                },
                {
                    id: 8,
                    label: "自我评价"
                },
                {
                    id: 11,
                    label: "业绩及奖惩情况"
                },
                {
                    id: 9,
                    label: "家庭成员"
                }
            ],
            adminData: [{
                id: 0,
                label: "账号信息"
            }, {
                id: 1,
                label: "修改密码"
            }],
            indexVli: "-1",//公司职位选择
            ruleFrom: {
                pageNum: 1,
                pageSize: 9999,
                tenantId: "",
            },
            posData: [],
            indexTd:"-1"
        }
    },
    watch: {
        companyData: {
            deep: true,
            handler(newObj, oldObj) {
                if (this.nav_value == 3) {
                    this.ruleFrom.tenantId = newObj.tenantId
                    this.loadings=true
                    this.positionListApi(this.ruleFrom)
                }

            }
        },
        refush:{
            deep: true,
            handler(newObj, oldObj) {
                console.log("监听刷新：",newObj,this.nav_value);
                if (this.nav_value == 0) {
                    this.indexTd=newObj==1?3:newObj==2?4:5
                    this.info()
                }else if(this.nav_value==1){

                }

            }
        }
    },
    created() {
        if (this.nav_value == 0) {
            this.nowData = this.nowDatas
            this.indexValue = 0
        } else if (this.nav_value == 1) {
            this.nowData = this.navData
            this.indexValue = 0
        } else if (this.nav_value == 2) {
            this.nowData = this.adminData
            this.indexValue = 0
        } else if (this.nav_value == 3) {

        }
    },
    mounted() {
        this.info()
    },
    methods: {
        dict(value, res) {
            return dictFuns(value, res)
        },
        info() {
            let obj = JSON.parse(sessionStorage.getItem("myInfornation"))
            console.log(obj);
            let personalInformation = obj.resumeVo.personalInformation
            let object = {
                sex: personalInformation ? personalInformation.gender ? personalInformation.gender : "-1" : "-1",
                name: personalInformation ? personalInformation.fullName ? personalInformation.fullName: "无名氏": "无名氏",
                deliveredCount: obj.deliveredCount,
                invitedCount: obj.invitedCount,
                collectedCount: obj.collectedCount,
                imageUrl: personalInformation ? personalInformation.photoUrl ? personalInformation.photoUrl : "" : "",
                age: personalInformation ? personalInformation.age ? personalInformation.age : "暂无年龄信息" : "暂无年龄信息",
                educationLevel: this.educationLevelFun(obj.resumeVo.educationExperiences),
                startWorkTime: this.startWorkTimeFun(personalInformation ? personalInformation.startWorkTime : "")
            }
            this.basic = object
        },
        educationLevelFun(res) {
            if (res.length != 0) {
                console.log(res);
                let number = res[res.length - 1].educationLevel ? res[res.length - 1].educationLevel : ""
                if (number == "") {
                    return "暂无学历信息"
                } else {
                    if (dictFuns(number, "education")) {
                        return dictFuns(number, "education")
                    } else {
                        return "暂无学历信息"
                    }

                }
            } else {
                return "暂无学历信息"
            }
        },

        startWorkTimeFun(res) {
            if (res) {
                let number = 0
                let date = new Date()
                let year = date.getFullYear();
                number = year - res.split("-")[0]
                if (number == 0) {
                    return ""
                } else {
                    return number + "年工作经验"
                }

            } else {
                return ""
            }
            let date = new Date()
        },
        go() {
            this.$router.push(`conpany_detail?id=${this.companyData.tenantId}`)
        },
        indexClick(item, index) {
            this.indexVli = index
            this.$router.push(`zhiwei_detail?id=${item.id}`)
            location.reload()
        },
        countClick(index) {
            this.indexValue = index
            this.indexTd=index
            this.$emit("asdiseClick", this.indexValue)

        },
        classClick(item) {
            this.indexTd="-1"
            this.indexValue = item.id
            if (this.nav_value == 0) {//首页
                if (this.indexValue == 0) {
                    console.log("首页");
                    this.$emit("asdiseClick", this.indexValue)
                } else if (this.indexValue == 1) {
                    console.log("投递进度");
                    this.$emit("asdiseClick", this.indexValue)
                } else if (this.indexValue == 2) {
                    this.$router.push("my")
                }

            } else if (this.nav_value == 1) {//我的简历
                this.$emit("asdiseClick", this.indexValue)
            } else {//账号
                if (this.indexValue == 0) {
                    this.$emit("asdiseClick", this.indexValue)
                } else if (this.indexValue == 1) {
                    this.$emit("asdiseClick", this.indexValue)
                }
            }
        },
        editClick() {
            this.edit = !this.edit
        },
        async positionListApi(params) {//首页职位投递
            // this.loading = true
            await positionList(params).then(res => {
                // this.loading = false
                console.log("侧边栏获取数据", res);
                this.posData = res.rows
            })
        },
        // async getDetailTenantApi(params) {//查询公司详细信息 
        //     await positionList(params).then(res => {
        //         console.log("侧边栏获取数据", res);
        //         this.posData = res.rows
        //     })
        // },
    }
}
</script>
  
<style scoped lang="scss">
.zhiweidetail_content {
    padding: 15px 22px;
}

.zhiweidetail_content_header {
    img {
        width: 90px;
        height: 90px;
        // margin-right: 18px;
        border-radius: 50%;
    }

    .zhiweidetail_content_header_main {
        img {
            width: 16px;
            height: 14px;
            margin-right: 2px;
        }
    }

    .zhiweidetail_content_header_r {
        img {
            width: 24px;
            height: 24px;
        }
    }

    padding-bottom: 24px;
    margin-bottom: 16px;
    border-bottom: 1px solid #D8D8D8;
}

.zhiweidetail_content_ul {
    padding: 0;
    height: 700px;
    overflow-y: auto;

    li {
        padding: 16px 18px;
        flex-direction: column;
        background: #F8F9FA;
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
        border: 1px solid #DCDFE6;
        display: flex;
        justify-content: space-between;
        margin-bottom: 16px;

        &:hover {
            background: #FFFFFF;
            border-radius: 0px 0px 0px 0px;
            opacity: 1;
            border: 1px solid #2F6CBC;
        }
    }

    .zhiweidetail_content_li {
        background: #FFFFFF;
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
        border: 1px solid #2F6CBC;
    }
}

.gary {
    color: #898989;
}

.red {
    color: #B60000
}

.asdise_content {
    width: 100%;
    min-height: 600px;
    max-height: 925px;
    background: #FFFFFF;
    border-radius: 0px 0px 0px 0px;
    opacity: 1;
    border: 1px solid #CACFD6;
    // padding: 0px 30px;

}

.asdise_content_title {
    line-height: 76px;
    padding-left: 22px;
    border-bottom: 1px solid #D8D8D8;
}

.asdise_content_main {
    .asdise_content_main_header {
        position: relative;
        margin: auto;
        margin-top: 26px;
        margin-bottom: 26px;
        width: 100px;
        height: 100px;

        .touxiang {
            width: 100px;
            height: 100px;
            border-radius: 50%;
        }

        .sex {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 35px;
            height: 35px;
            opacity: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 50%;

            img {
                width: 24px;
                height: 24px;
            }
        }

        .nan {
            z-index: 9;
            background: #2F6CBC;
        }

        .nv {
            z-index: 9;
            background: #FE6470;
        }
    }
}

.asdise_content_main_name {
    position: relative;
    margin-bottom: 20px;

    .asdise_content_main_name_edit {
        position: absolute;
        right: 72px;
    }

    .asdise_content_main_name_input {
        width: 120px;
    }
}
.td_grid{
    // padding: 0px 21px;
    display: grid;
    grid-template-columns: repeat(3,33.33%);
}
.asdise_content_main_name_div {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60px;
    p{
        margin: 0;
    }
    .garys{
        color: #898989;
    }
    .garys_{
        color: #000000;
    }

}
.asdise_content_main_name_divs{
    height: 60px;
    background-color: #2F6CBC;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    p{
        margin: 0;
    }
    .garys{
        color: #FFFFFF;
    }
    .garys_{
        color: #FFFFFF;
    }


}

.asdise_content_ul {
    list-style: none;
    padding: 0;

    li {
        padding: 0px 21px;
        line-height: 48px;
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
        display: flex;
        justify-content: space-between;
        align-items: center;

        img {
            width: 24px;
            height: 24px;
        }
    }

    .blue {
        color: #FFFFFF;
        background: #2F6CBC;
    }
}
</style>
  